package com.hxy.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;


import java.io.Serializable;
import java.util.Collection;

/**
 * <p>
 * 
 * </p>
 *
 * @author jobob
 * @since 2021-07-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class Buser implements UserDetails {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String ume;

    private String pwd;
    private Integer locked;
    private Integer expired;
    private Integer iscreexpired;
    private Integer isenable;
    private Collection authorities;
    public Collection<? extends GrantedAuthority> setAuthorities(Collection collection) {
        return this.authorities = collection;
    }


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUme() {
        return ume;
    }

    public void setUme(String ume) {
        this.ume = ume;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public Integer getLocked() {
        return locked;
    }

    public void setLocked(Integer locked) {
        this.locked = locked;
    }

    public Integer getExpired() {
        return expired;
    }

    public void setExpired(Integer expired) {
        this.expired = expired;
    }

    public Integer getIsenable() {
        return isenable;
    }

    public void setIsenable(Integer isenable) {
        this.isenable = isenable;
    }

    //设置角色和权限
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }
    //获取密码
    @Override
    public String getPassword() {
        return this.pwd;
    }
    //获取账号
    @Override
    public String getUsername() {
        return this.ume;
    }
    //判断账户是否过期
    @Override
    public boolean isAccountNonExpired() {
        return this.expired==0?true :false;
    }
    //判断账户是否被锁定
    @Override
    public boolean isAccountNonLocked() {
        return this.locked==0?true:false;
    }

    public Integer getIscreexpired() {
        return iscreexpired;
    }

    public void setIscreexpired(Integer iscreexpired) {
        this.iscreexpired = iscreexpired;
    }

    //判断凭证是否过期
    @Override
    public boolean isCredentialsNonExpired() {
        return this.iscreexpired==0?true:false;
    }
    //判断是否启用
    @Override
    public boolean isEnabled() {
        return this.isenable==0?true:false;
    }
}
